package com.crm.system.controller.csd.customerManager;

import com.crm.common.model.DataResponse;
import com.crm.common.model.DhPageInfo;
import com.crm.common.model.DhResponse;
import com.crm.common.model.Enum.ResponseCodeEnum;
import com.crm.model.entity.csd.product.sceneChangeCourse;
import com.crm.model.qo.csd.product.SceneChangeCourseQO;
import com.crm.model.vo.csd.product.*;
import com.crm.model.vo.finishOrderProduct.FinishOrderProductVO;
import com.crm.model.vo.productManager.CustomerMemberProductVO;
import com.crm.model.vo.productManager.CustomerProductVO;
import com.crm.system.service.csd.customerManager.ProductExchangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 产品兑换
 * @author wangpeng
 * @Date 2021/9/8
 */
@RestController
@RequestMapping("/csd/ProductExchange")
public class ProductExchangeController {

    @Autowired
    private ProductExchangeService productExchangeService;


    /**
     * selectProductSceneList
     * 产品兑换-现场参会数兑换课程
     * @Author wangpeng
     * @Date 2021/9/8
     * @param request
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @return
     */
    @PostMapping("/selectProductSceneList")
    private DataResponse selectProductSceneList(HttpServletRequest request,
                                                      @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                      @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                      @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                      @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                      Integer enableDisable
                                                      ){
       try {
           DhPageInfo<sceneChangeCourseVO> list = productExchangeService.selectProductSceneList(pageIndex,pageSize,sortName,sortOrder,enableDisable);
           return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
       }catch (Exception e){
           return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
       }
    }

    /**
     * selectProductIndustryList
     * 产品兑换-专行业交流兑换课程
     * @Author wangpeng
     * @Date 2021/9/8
     * @param request	
     * @param pageIndex	
     * @param pageSize	
     * @param sortName	
     * @param sortOrder	
     * @return
     */
    @PostMapping("/selectProductIndustryList")
    private DataResponse selectProductIndustryList(HttpServletRequest request,
                                                @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                Integer enableDisable
    ){
        try {
            DhPageInfo<industryChangeCourseVO> list = productExchangeService.selectProductIndustryList(pageIndex,pageSize,sortName,sortOrder,enableDisable);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }

    /**
     * selectProductHighClassList
     * 产品兑换-高端班价格兑换课程
     * @Author wangpeng
     * @Date 2021/9/8
     * @param request
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @return
     */
    @PostMapping("/selectProductHighClassList")
    private DataResponse selectProductHighClassList(HttpServletRequest request,
                                                   @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                   @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                   @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                   @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                    Integer enableDisable
    ){
        try {
            DhPageInfo<highClassChangeCourseVO> list = productExchangeService.selectProductHighClassList(pageIndex,pageSize,sortName,sortOrder,enableDisable);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }


    /**
     * selectProductList
     * 产品兑换-添加规则 非会员产品列表
     * @Author wangpeng
     * @Date 2021/9/10
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @param productName	产品名称
     * @return
     */
    @PostMapping("/selectProductList")
    public DataResponse selectProductList(@RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                          @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                          @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                          @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                          String productName

    ){
        try {
            DhPageInfo<CustomerProductVO> list = productExchangeService.selectProductList(pageIndex,pageSize,sortName,sortOrder,productName);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            e.printStackTrace();
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }

    }

    /**
     * selectHighCustomerMemberProductList
     * @Author wangpeng
     * @Date 2021/11/24
     * @param pageIndex	
     * @param pageSize	
     * @param sortName	
     * @param sortOrder	
     * @param productName	
     * @return
     *  会员列表
     */
    @PostMapping("/selectHighCustomerMemberProductList")
    public DataResponse selectHighCustomerMemberProductList(@RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                            @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                            @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                            @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                            String productName

    ){
        try {
            DhPageInfo<CustomerMemberProductVO> list = productExchangeService.selectHighCustomerMemberProductList(pageIndex,pageSize,sortName,sortOrder,productName);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            e.printStackTrace();
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }

    }
    

    /**
     * addProductScene
     * 产品兑换-添加规则-现场参会数兑换课程
     * @Author wangpeng
     * @Date 2021/9/10
     * @param sceneParameterDays	兑换次数
     * @param changeCourseTitle	    课程名称
     * @param courseProductCode	兑换课程产品编码
     * @return
     */
    @PostMapping("/addProductScene")
    private DataResponse addProductScene(Integer sceneParameterDays,String changeCourseTitle,String courseProductCode,String finishOrderProductNum,String productType,String ruleTitle){
        try {
            Boolean result= productExchangeService.addProductScene(sceneParameterDays,changeCourseTitle,courseProductCode,finishOrderProductNum,productType,ruleTitle);
            if (result){
                return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
            }
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }

    /**
     * addProductIndustry
     * 产品兑换-添加规则-专行业交流兑换课程
     * @Author wangpeng
     * @Date 2021/9/10
     * @param industryExchangeNumber 交流次数
     * @param changeCourseTitle	  课程名称
     * @param courseProductCode	兑换课程产品编码
     * @return
     */
    @PostMapping("/addProductIndustry")
    private DataResponse addProductIndustry(Integer industryExchangeNumber,String changeCourseTitle,String courseProductCode,String finishOrderProductNum,String productType,String ruleTitle){
        try {
            Boolean result= productExchangeService.addProductIndustry(industryExchangeNumber,changeCourseTitle,courseProductCode,finishOrderProductNum,productType,ruleTitle);
            if (result){
                return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
            }
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }

    /**
     * addProductHighClass
     * 产品兑换-添加规则-高端班按价格兑换课程
     * @Author wangpeng
     * @Date 2021/10/28
     * @param courseProductCode
     * @param productName
     * @param changeCourseTitle
     * @param productCode
     * @param finishOrderProductNum
     * @param courseOriginalPrice
     * @return
     */
    @PostMapping("/addProductHighClass")
    private DataResponse addProductHighClass(String courseProductCode, String productName,String changeCourseTitle,String productCode,String finishOrderProductNum,String courseOriginalPrice,String productType,String ruleTitle){
        try {
            Boolean result= productExchangeService.addProductHighClass(courseProductCode,productName,changeCourseTitle,productCode,finishOrderProductNum,courseOriginalPrice,productType,ruleTitle);
            if (result){
                return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
            }
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }


    /**
     * updateEnableDisable
     * @Author wangpeng
     * @Date 2021/10/25
     * @param id   主键ID
     * @param enableDisable 1:启用  2停用
     * @param type	1：现场 2:行会；3：高端班; 4：高端班兑换现场天数;5现场天数换行业会；6行业会换现场天数
     * @return
     */
    @PostMapping("/updateEnableDisable")
    private DataResponse updateEnableDisable(String id,String enableDisable,Integer type){
        try {
            Boolean result= productExchangeService.updateEnableDisable(id,enableDisable,type);
            if (result){
                return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
            }
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }

    /**
     * selectChangeCourseRecord
     * 产品管理-产品兑换-兑换列表
     * @Author wangpeng
     * @Date 2021/9/26
     * @param request
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @param vo
     * @return
     */
    @PostMapping("/selectChangeCourseRecord")
    private DataResponse selectChangeCourseRecord(HttpServletRequest request,
                                                @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                ChangeCourseRecordVO vo
    ){
        try {
            DhPageInfo<ChangeCourseRecordVO> list = productExchangeService.selectChangeCourseRecord(pageIndex,pageSize,sortName,sortOrder,vo);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }


    /**
     * selectHighClassExchangeDaysList
     * 高端班兑换现场天数列表
     * @Author wangpeng
     * @Date 2021/10/22
     * @param request
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @return
     */
    @PostMapping("/selectHighClassExchangeDaysList")
    private DataResponse selectHighClassExchangeDaysList(HttpServletRequest request,
                                                   @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                   @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                   @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                   @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                   Integer enableDisable
    ){
        try {
            DhPageInfo<highClassExchangeDaysVO> list = productExchangeService.selectHighClassExchangeDaysList(pageIndex,pageSize,sortName,sortOrder,enableDisable);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }

    /**
     * addHighClassExchangeDays
     * 新增高端班兑换现场天数列表
     * @Author wangpeng
     * @Date 2021/10/27
     * @param exchangeDays
     * @param productName
     * @param productCode
     * @param finishOrderProductNum
     * @return
     */
    @PostMapping("/addHighClassExchangeDays")
    private DataResponse addHighClassExchangeDays(Integer exchangeDays,String productName,String productCode,String finishOrderProductNum,String ruleTitle){
        try {
            Boolean result= productExchangeService.addHighClassExchangeDays(exchangeDays,productName,productCode,finishOrderProductNum,ruleTitle);
            if (result){
                return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
            }
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }


    /**
     * selectSiteExchangeIndustryList
     * 现场天数兑换行业会
     * @Author wangpeng
     * @Date 2021/10/28
     * @param request
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @param enableDisable	是否启用
     * @return
     */
    @PostMapping("/selectSiteExchangeIndustryList")
    private DataResponse selectSiteExchangeIndustryList(HttpServletRequest request,
                                                         @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                         @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                         @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                         @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                         Integer enableDisable
    ){
        try {
            DhPageInfo<siteExchangeIndustryVO> list = productExchangeService.selectSiteExchangeIndustryList(pageIndex,pageSize,sortName,sortOrder,enableDisable);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }


    /**
     * addSiteExchangeIndustry
     * 新增现场天数兑换行业会
     * @Author wangpeng
     * @Date 2021/10/28
     * @param siteDays
     * @param industryNumber
     * @return
     */
    @PostMapping("/addSiteExchangeIndustry")
    private DataResponse addSiteExchangeIndustry(Integer siteDays,Integer industryNumber,String ruleTitle){
        try {
            Boolean result= productExchangeService.addSiteExchangeIndustry(siteDays,industryNumber,ruleTitle);
            if (result){
                return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
            }
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }


    /**
     * selectIndustryExchangeSiteList
     * 行业会兑换现场天数
     * @Author wangpeng
     * @Date 2021/10/28
     * @param request
     * @param pageIndex
     * @param pageSize
     * @param sortName
     * @param sortOrder
     * @param enableDisable
     * @return
     */
    @PostMapping("/selectIndustryExchangeSiteList")
    private DataResponse selectIndustryExchangeSiteList(HttpServletRequest request,
                                                        @RequestParam(value = "pageIndex", required = true) Integer pageIndex,//页码
                                                        @RequestParam(value = "pageSize", required = true) Integer pageSize,//分页大小
                                                        @RequestParam(value="sortName",required = false) String sortName,//排序列名字
                                                        @RequestParam(value="sortOrder",required = false) String sortOrder,//排序规则(asc/desc
                                                        Integer enableDisable
    ){
        try {
            DhPageInfo<industryExchangeSiteVO> list = productExchangeService.selectIndustryExchangeSiteList(pageIndex,pageSize,sortName,sortOrder,enableDisable);
            return new DhResponse(ResponseCodeEnum.OK.getResponseCode(),list);
        }catch (Exception e){
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }

    /**
     * addSiteExchangeIndustry
     * 新增行业会兑换现场天数
     * @Author wangpeng
     * @Date 2021/10/28
     * @param siteDays
     * @param industryNumber
     * @return
     */
    @PostMapping("/addIndustryExchangeSite")
    private DataResponse addIndustryExchangeSite(Integer siteDays,Integer industryNumber,String ruleTitle){
        try {
            Boolean result= productExchangeService.addIndustryExchangeSite(siteDays,industryNumber,ruleTitle);
            if (result){
                return new DhResponse(ResponseCodeEnum.OK.getResponseCode());
            }
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }catch (Exception e){
            e.printStackTrace();
            return new DhResponse(ResponseCodeEnum.ERROR.getResponseCode());
        }
    }




}
